/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package di.util;

import di.server.log.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 *
 * @author Kilian Ito
 */
public class ConstantsInit extends HttpServlet {

    private static final long serialVersionUID = 1L;
    private Logger logger = Logger.getLogger(ConstantsInit.class);
    protected final Properties properties = new Properties();

    @Override
    public void init(ServletConfig config) throws ServletException {
        ServletContext sc = config.getServletContext();
        Enumeration<String> configs = config.getInitParameterNames();
        final String webAppPath = sc.getRealPath("/");
        
        while(configs.hasMoreElements()) {
            String conf = configs.nextElement();
            String path = webAppPath + config.getInitParameter(conf);
            logger.log(Level.DEBUG, "Loading Constants File '"+path+"'");
            DIIO.setConstantsFile(path);
        }
        super.init(config);
    }
}